import { throttle } from "~/utils/index";

const echartResize = chart => {
  if (!chart) throw Error("请传入echart实例");
  const callback = () => {
    chart?.resize();
  };

  window.addEventListener("resize", throttle(callback));

  onBeforeUnmount(() => {
    window.removeEventListener("resize", callback);
  });
};

const echartFontSetting = () => {
  return {
    textStyle: {
      fontFamily: "XingShu", // 设置字体
      color: "#333", // 设置颜色
    },
  };
};

export default function () {
  return { echartResize, echartFontSetting };
}
